{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-header">
        <div class="layui-form-item">
            <form action="{:url('admin/user/index')}" class="layui-form" method="get">
                <div class="layui-inline" style="padding-left: 0px;">
                    <a href="{:url('admin/user/add')}" class="layui-btn ajax-iframe" data-width="500px">新增</a>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">关键字：</label>
                    <div class="layui-input-inline mr0">
                        <input name="keywords" class="layui-input" value="{:input('keywords')}" type="text" placeholder="请输入名称" autocomplete="off"/>
                    </div>
                </div>
               
                <div class="layui-inline" style="padding-left: 20px;">
                    <button class="layui-btn layui-btn-primary ajax-search"><i class="fa fa-search"></i> 搜索</button>
                </div>
            </form>
        </div>
    </div>
    
    <table id="tableList" lay-filter="tableList"></table>
    <!-- 表格操作列 -->
    <script type="text/html" id="tableTBTrack">
        <a href="{:url('admin/user/edit')}?id={{d.id}}" class="layui-btn layui-btn-sm ajax-iframe" data-width="500px">修改</a>
        <a href="{:url('admin/user/del')}?id={{d.id}}" class="layui-btn layui-btn-sm layui-btn-danger ajax-delete">删除</a>
    </script>
    <!-- 权限列 -->
    <script type="text/html" id="status">
        <input type="checkbox" name="status" lay-skin="switch" lay-filter="*" lay-text="正常|禁用" data-url="{:url('admin/user/edit')}?id={{d.id}}" {{d.status==1?'checked':''}}>
    </script>
    <!-- 权限列 -->
    <script type="text/html" id="sort_order">
        <input type="text" name="sort_order" value="{{d.sort_order}}" autocomplete="off" class="layui-input ajax-update" data-url="{:url('admin/user/edit')}?id={{d.id}}">
    </script>
</div>
{/block}

{block name="js"}
<script>
    layui.use(['layer', 'form', 'table', 'util', 'dropdown','laytpl'], function () {

        var table = layui.table;

        // 渲染回访表格
        var insTb = table.render({
            elem: '#tableList',
            url: "{:url('admin/user/index_json')}",
            where:{
                keywords:"{:input('keywords')}"
            },
            page: true,
            cellMinWidth: 100,
            //toolbar:true ,
            limit:'15',
            limits:[15,30,50,100,200,500],
            size:'lg',even:true,
            cols: [[
                {type:'numbers',title:'#'},
                {align: 'center', templet: function (d) {
                        if(d.avatarurl){
                            return '<img src="' + d.avatarurl + '" class="tdImg" tb-img/>';
                        }else{
                            return '<img src="/static/img/no_image_100x100.jpg" class="tdImg" tb-img/>';
                        }
                    }, title: '头像', width: 90, unresize: true
                },
                {field: 'nickname', align: 'left',width:150, sort: true, title: '昵称'},
                {field: 'mobile', align: 'left', sort: true, title: '手机号码'},
                {field: 'name', align: 'left', sort: true, title: '用户姓名'},
                {field: 'create_time', align: 'center', sort: true, title: '创建时间'},
                {align: 'center', sort: true, title: '状态',templet:'#status'},
                {align: 'center', toolbar: '#tableTBTrack', title: '操作',minWidth:220}
            ]],
            parseData: function(res){ //res 即为原始返回的数据
                return {
                  "code": res.code, //解析接口状态
                  "msg": res.msg, //解析提示文本
                  "count": res.data.total, //解析数据长度
                  "data": res.data.data //解析数据列表
                };
            }
        });
    });
</script>
{/block}